package br.com.ia.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import br.com.enovar.trex.struts.form.TRexBaseForm;

public class ValorForm extends TRexBaseForm {

	private Integer codigo;
	private String descricao;
	private Integer codigoVariavelPai;

	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Integer getCodigoVariavelPai() {
		return codigoVariavelPai;
	}

	public void setCodigoVariavelPai(Integer codigoVariavelPai) {
		this.codigoVariavelPai = codigoVariavelPai;
	}

	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {

		codigo = null;
		descricao = null;
		codigoVariavelPai = null;

		super.reset(mapping, request);
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();

		String param = mapping.getParameter();
		String method = request.getParameter(param);
		if (method.matches("insert|update")) {
			errors = super.validate(mapping, request);
		}

		return errors;
	}
}
